package leetcode.editor.cn.q1_300.q150;

/**
 * @author qidi
 * @date 2022-02-10 14:42:27
 */
class Q0167_TwoSumIiInputArrayIsSorted {

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int[] twoSum(int[] numbers, int target) {
            int l = 0, r = numbers.length - 1;

            while (l < r) {
                int res = numbers[l] + numbers[r];
                if (res > target) {
                    r--;
                } else if (res < target) {
                    l++;
                } else {
                    break;
                }
            }

            return new int[]{l + 1, r + 1};
        }
    }
    //leetcode submit region end(Prohibit modification and deletion)


    public static void main(String[] args) {
        Solution solution = new Q0167_TwoSumIiInputArrayIsSorted().new Solution();
    }
}